home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TA2ASV08.ZIP / MEEN.C < prev    next >
C/C++ Source or Header  |  1994-07-04  |  2KB  |  75 lines

  1. /* TA2AS INTEL(TASM) TO AT&T(AS) CONVERTER, MAIN MODULE
  2.    COPYRIGHT 1994 FRANK VAN DIJK, LAST UPDATE M6-21-94    11:03
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include "ta2as.h"
  8.  
  9. int main(int narg,char** argv)
  10. {
  11. /* Dit is een testmain*/
  12. FILE *in,*uit;
  13. int hoeveel,teller;
  14. cbuf b0,b1,b2,b3;
  15. oprd ops[32];
  16. for(teller=0;teller<32;ops[teller++].flags=0);
  17. if (narg!=3)
  18.     {
  19.     puts("Ta2As 0.8 - Copyright 1994 FRANK VAN DIJK\n\r"
  20.          "Converts Tasm intel assembler to AT&T syntax (GNU As)\n\r"
  21.          "Usage: Ta2As inputfile outputfile\n\n\r");
  22.     return 1;
  23.     }
  24. if(!(in=fopen(argv[1],"r"))) return 1;
  25. if(!(uit=fopen(argv[2],"w"))) return 1;
  26. while(fgets(b0,255,in))
  27.     {
  28.     int sizesuf=0;
  29.     *b1=*b2=*b3=0;
  30.     hoeveel=strlen(b0);
  31.     if(hoeveel) b0[hoeveel-1]=0;
  32.     ChopEm(b0,b1,b2,b3,ops,&hoeveel);
  33.     ModLine(b1,b2,b3,ops,&hoeveel);
  34.     if(*b1||*b2)
  35.         {
  36.         fputs(b1,uit);
  37.         fputc('\t',uit);
  38.         sizesuf=0;
  39.         for(teller=0;teller<hoeveel;teller++)
  40.             {
  41.             Operand2Operand(&ops[teller]);
  42.             sizesuf|=ops[teller].flags;
  43.             ops[teller].flags=0;
  44.             }
  45.         if((!strcmp(b2,"out")||!strcmp(b2,"in"))&&sizesuf!=2)
  46.             sizesuf&=~2;
  47.         if (sizesuf&1) strcat(b2,"b");
  48.         if (sizesuf&2) strcat(b2,"w");
  49.         if (sizesuf&4) strcat(b2,"l");
  50.         fputs(b2,uit);
  51.         fputc('\t',uit);
  52.         if(strcmp(b2,".byte")&&strcmp(b2,".short")&&strcmp(b2,".int")&&strcmp(b1,".equ"))
  53.             for(teller=hoeveel-1;teller>=0;)
  54.                 {
  55.                 fputs(ops[teller--].op,uit);
  56.                 if (teller>=0) fputc(',',uit);
  57.                 }
  58.         else    for(teller=0;teller<hoeveel;)
  59.                 {
  60.                 if(*ops[teller].op=='$')
  61.                     memmove(ops[teller].op,ops[teller].op+1,strlen(ops[teller].op));
  62.                 fputs(ops[teller++].op,uit);
  63.                 if(teller<hoeveel) fputc(',',uit);
  64.                 }
  65.         if(*b3) fputc('\t',uit);
  66.         }
  67.     if(*b3)
  68.       fputs(b3,uit);
  69.     fputs("\n",uit);
  70.     }
  71. fclose(in);
  72. fclose(uit);
  73. return 0;
  74. }
  75.